<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head><link rel="stylesheet" type="text/css" href="style.css">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Registration</title>
</head>
<body>
<h3>Please Enter Your Details.  </h3>


<form name="registerUser" action="Register.do" method="get"  onsubmit="return validateForm();">
<table border="0" >
                    <tr>
                        <td> First Name	: </td><td> <input name="first_name" size=15 type="text" /> </td> 
                    </tr>
                    <tr><td> Last Name	: </td><td> <input name="last_name" size=15 type="text" /> </td> </tr> 
                    <tr><td> Sex		: </td><td> <input type="radio" name="sex" value="male">Male
<input type="radio" name="sex" value="female">Female </td> </tr>  
<tr><td> Country		: </td><td> <select name = "country">
  <option value="India">India</option>
  <option value="Sri Lanka">Sri Lanka</option>
  <option value="United States">United States</option>
  <option value="Finland">Finland</option>
</select> 
</td> </tr>                 
                    <tr>
                        <td> Email Address	: </td><td> <input name="emailaddress" size=50 type="text" /> </td> 
                    </tr>
                    <tr>
                        <td> Password	: </td><td> <input name="password" size=15 type="password" /> </td> 
                    </tr>
                    <tr>
                        <td> Re-enter Password	: </td><td> <input name="Repassword" size=15 type="password" /> </td> 
                    </tr>
                    
                </table>
                <br></br>
                <INPUT TYPE="SUBMIT" VALUE="Register">
                </form>
                

<script>



function validateForm()
{
var x=document.forms["registerUser"]["first_name"].value;
if (x==null || x=="")
  {
  alert("Please Enter Your First Name");
  return false;
  }

var x=document.forms["registerUser"]["last_name"].value;
if (x==null || x=="")
  {
  alert("Please Enter Your Last Name");
  return false;
  }
if ( ( registerUser.sex[0].checked == false ) && ( registerUser.sex[1].checked == false ) ) 
{
alert ( "Are you shemale??" ); 
return false;
}

var x=document.forms["registerUser"]["emailaddress"].value;
var atpos=x.indexOf("@");
var dotpos=x.lastIndexOf(".");
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
  {
  alert("Not a valid e-mail address");
  return false;
  }
if (x==null || x=="")
  { 
  alert("Please Enter Your Email Address");
  return false;
  }        
var x=document.forms["registerUser"]["password"].value;
if ( x=="" || x==null) 
  { 
  alert("Please Enter a Password");
  return false;
  }  
var y=document.forms["registerUser"]["Repassword"].value;
if ( (x!=y)) 
  { 
  alert("Passwords do not match");
  return false;
  }  
}
</script>
</body>
</html>
